<?php

import('classes.handler.Handler');
class DMHandler extends Handler {
		// call from indexHandler
	function KT_DANHMUC($args, &$request) {
		$xSection = Request::getUserVar("ChiTiet");
		$templateMgr =& TemplateManager::getManager();
		$templateMgr->addStyleSheet($request->getBaseUrl().'/styles/dm.css');


		$templateMgr->addJavaScript("lib/pkp/js/lib/jquery/jquery.min.js");
		//$templateMgr->addJavaScript('classes/acct/js/danhmuc.js');

		$newurlIns = PKPRequest::getProtocol()."://". PKPRequest::getServerHost().PKPRequest::getBasePath()."/pages/acctKT/i_DMTK.php";

		$newurl = Request::url(null, null, null, null, array('ChiTiet' => $xSection));
		//echo $newurl ;
		$templateMgr->assign('url', $newurl );


		$templateMgr->addJavaScript('lib/pkp/js/lib/jquery/plugins/validate/jquery.validate.min.js');
		$templateMgr->addJavaScript('lib/pkp/js/jqueryValidatorI18n.js');

		$dmntDao =& DAORegistry::getDAO('DMNTDAO');


		$host =  $dmntDao->_dataSource->host;
		$username =  $dmntDao->_dataSource->user;
		$password  = $dmntDao->_dataSource->password;
		$databaseName = $dmntDao->_dataSource->databaseName;
		
		$templateMgr->assign('urlIns', $newurlIns);
		$templateMgr->assign('host', $host);
		$templateMgr->assign('username', $username);
		$templateMgr->assign('password', $password);
		$templateMgr->assign('databaseName', $databaseName);


		if ($xSection == "TK")
		{

			$dmtkDao =& DAORegistry::getDAO('DMTKDAO');
			// them phan Search


			$user =& Request::getUser();
			$userId = $user->getId();
			$xma_dvcs = $user->getPath();


			$searchType = null;
			$searchMatch = null;
			$search = Request::getUserVar('search');

			$searchInitial = Request::getUserVar('searchInitial');
			if (!empty($search)) {
				$searchType = Request::getUserVar('searchField');
				$searchMatch = Request::getUserVar('searchMatch');

			} elseif (!empty($searchInitial)) {
				$searchInitial = String::strtoupper($searchInitial);
				$searchType = USER_FIELD_INITIAL;
				$search = $searchInitial;
			}

			$fieldOptions = Array(
			DMTK_FIELD_MATK => 'M&#227; TK',
			DMTK_FIELD_TENTK => 'T&#234;n TK',
			DMTK_FIELD_TK_ME => 'Tài khoản mẹ',
				);

			$templateMgr->assign('fieldOptions', $fieldOptions);

			$templateMgr->assign('searchField', $searchType);
			$templateMgr->assign('searchMatch', $searchMatch);
			$templateMgr->assign('search', $search);
			$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));

			if (!empty($search)) {
			$fieldName = $searchType;
			switch ($searchMatch) {
				case 'is':
					$searchSql = "($fieldName = $search)";
					break;
				case 'contains':
					$searchSql = "($fieldName có chứa $search)";
					break;
				case 'startsWith':
					$searchSql = "($fieldName bắt đầu là $search)";
					break;
				}
			}
			$templateMgr->assign('searchSql', $searchSql);

			$dmtks =& $dmtkDao->getDMTKSearch($searchType, $search, $searchMatch);
			$templateMgr->assign_by_ref('dmtks', $dmtks);
			$templateMgr->assign('DM_SecDetail', "Danh mục Tài Khoản");
			$templateMgr->display('acctKT/DMTK.tpl');

		}  //if ($xSection == "TK")
		else if ($xSection == "DV")
		{
			$dmDao =& DAORegistry::getDAO('DMDVDAO');
			$journalid = 3;
				
			$dmdv_initial =  Request::getUserVar("dmdv_initial");
			if (!$dmdv_initial)
				$dmdv_initial = "0";

	
			$templateMgr->assign('dmdv_initial',  $dmdv_initial);
			$templateMgr->assign('alphaList', explode(' ', __('common.InitList')));

			$searchType = null;
			$searchMatch = null;
			$search = Request::getUserVar('search');
			$searchInitial = Request::getUserVar('searchInitial');
			if (!empty($search)) {
				$searchType = Request::getUserVar('searchField');
				$searchMatch = Request::getUserVar('searchMatch');

			} elseif (!empty($searchInitial)) {
				$searchInitial = String::strtoupper($searchInitial);
				$searchType = USER_FIELD_INITIAL;
				$search = $searchInitial;
			}

			$fieldOptions = Array(
			DMDV_FIELD_MA => 'Mã Đơn vị ',
			DMDV_FIELD_TEN => 'Tên đơn vị',
			DMDV_FIELD_DAIDIEN => 'Đại diện',
			DMDV_FIELD_DIACHI => 'Địa chỉ'
			);

			$templateMgr->assign('fieldOptions', $fieldOptions);

			$templateMgr->assign('searchField', $searchType);
			$templateMgr->assign('searchMatch', $searchMatch);
			$templateMgr->assign('search', $search);
			$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));

			if (!empty($search)) {
			$fieldName = $searchType;
			switch ($searchMatch) {
				case 'is':
					$searchSql = "($fieldName = $search)";
					break;
				case 'contains':
					$searchSql = "($fieldName có chứa $search)";
					break;
				case 'startsWith':
					$searchSql = "($fieldName bắt đầu là $search)";
					break;
				}
				$dktim= $searchSql;
				$dmdvas = $dmDao->getDMSearch($searchType, $search, $searchMatch);

				$templateMgr->assign('searchSql', $searchSql);
				//$dmvtas = $dmDao->getSettingDM($journalid, $dmvt_initial);

			}
			else{
				$dktim= "Các Chi tiết bắt đầu là <b>$dmdv_initial";
				$dmdvas = $dmDao->getSettingDM($journalid, $dmdv_initial);

			};

			$templateMgr->assign('DM_SecDetail', "Danh mục Đơn vị");
			$templateMgr->assign('dmdvas',  $dmdvas);

			$templateMgr->assign('dktim',  $dktim);

			$templateMgr->display('acctKT/DMDV.tpl');

		}
		else if ($xSection == "NT")
		{
			$dmntDao =& DAORegistry::getDAO('DMNTDAO');
			// them phan Search

			$user =& Request::getUser();
			$userId = $user->getId();
			$xma_dvcs = $user->getPath();

			$searchType = null;
			$searchMatch = null;
			$search = Request::getUserVar('search');
			$searchInitial = Request::getUserVar('searchInitial');
			if (!empty($search)) {
				$searchType = Request::getUserVar('searchField');
				$searchMatch = Request::getUserVar('searchMatch');

			} elseif (!empty($searchInitial)) {
				$searchInitial = String::strtoupper($searchInitial);
				$searchType = USER_FIELD_INITIAL;
				$search = $searchInitial;
			}



			//ss
			$fieldOptions = Array(
			DMNT_FIELD_MANT => 'M&#227; Tiền tệ',
			DMNT_FIELD_TENNT => 'Loại tiền tệ'
				);


			$templateMgr->assign('fieldOptions', $fieldOptions);

			$templateMgr->assign('searchField', $searchType);
			$templateMgr->assign('searchMatch', $searchMatch);
			$templateMgr->assign('search', $search);
			$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));

			$dms =& $dmntDao->getDMNTSearch($searchType, $search, $searchMatch);
			$templateMgr->assign_by_ref('dms', $dms);
			$templateMgr->assign('DM_SecDetail', "Danh mục Loại tiền tệ");
			$templateMgr->display('acctKT/DMNT.tpl');

		}
		else if ($xSection == "KHO")
		{
			$dmDao =& DAORegistry::getDAO('DMDVDAO');
			$journalid = 3;
				
			$dmdv_initial =  Request::getUserVar("dmdv_initial");
			if (!$dmdv_initial)
				$dmdv_initial = "0";

			$dmdvString = $dmDao->getSetting($journalid, $dmdv_initial);
			$dmdvas = $dmDao->getSettingDM($journalid, $dmdv_initial);
	
			$templateMgr->assign('dmdv_initial',  $dmdv_initial);


			$templateMgr->assign('alphaList', explode(' ', __('common.InitList')));

			$templateMgr->assign('dmdvas',  $dmdvas);
			
			// them phan Search
			$user =& Request::getUser();
			$userId = $user->getId();
			$xma_dvcs = $user->getPath();


			$searchType = null;
			$searchMatch = null;
			$search = Request::getUserVar('search');
			$searchInitial = Request::getUserVar('searchInitial');
			if (!empty($search)) {
				$searchType = Request::getUserVar('searchField');
				$searchMatch = Request::getUserVar('searchMatch');

			} elseif (!empty($searchInitial)) {
				$searchInitial = String::strtoupper($searchInitial);
				$searchType = USER_FIELD_INITIAL;
				$search = $searchInitial;
			}

			$fieldOptions = Array(
			DMTK_FIELD_MATK => 'M&#227; TK',
			DMTK_FIELD_TENTK => 'T&#234;n TK'
				);

			$templateMgr->assign('fieldOptions', $fieldOptions);

			$templateMgr->assign('searchField', $searchType);
			$templateMgr->assign('searchMatch', $searchMatch);
			$templateMgr->assign('search', $search);
			$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));


			$templateMgr->assign('DM_SecDetail', "Danh mục Đơn vị");
			$templateMgr->display('acctKT/DMDV.tpl');

		}
		else if ($xSection == "VT")
		{
			$dmDao =& DAORegistry::getDAO('DMVTDAO');
			$journalid = 3;
				
			$dmvt_initial =  Request::getUserVar("dmvt_initial");
			if (!$dmvt_initial)
				$dmvt_initial = "0";

			$templateMgr->assign('dmvt_initial',  $dmvt_initial);
			$templateMgr->assign('alphaList', explode(' ', __('common.InitList')));
			
			// them phan Search
			$searchType = null;
			$searchMatch = null;
			$search = Request::getUserVar('search');
			$searchInitial = Request::getUserVar('searchInitial');
			if (!empty($search)) {
				$searchType = Request::getUserVar('searchField');
				$searchMatch = Request::getUserVar('searchMatch');

			} elseif (!empty($searchInitial)) {
				$searchInitial = String::strtoupper($searchInitial);
				$searchType = USER_FIELD_INITIAL;
				$search = $searchInitial;
			}

			$fieldOptions = Array(
			DMVT_FIELD_MA => 'Mã VT',
			DMVT_FIELD_TEN => 'T&#234;n Vật tư',
			DMVT_FIELD_DVT=>'Đơn vị tính',
			DMVT_FIELD_TKVT=>'TK Vật tư',
			DMVT_FIELD_TKDT=>'TK Doanh thu',
			DMVT_FIELD_TKGV=>'TK Giá vốn');

			$templateMgr->assign('fieldOptions', $fieldOptions);

			$templateMgr->assign('searchField', $searchType);
			$templateMgr->assign('searchMatch', $searchMatch);
			$templateMgr->assign('search', $search);
			$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));

			if (!empty($search)) {
			$fieldName = $searchType;
			switch ($searchMatch) {
				case 'is':
					$searchSql = "($fieldName = $search)";
					break;
				case 'contains':
					$searchSql = "($fieldName có chứa $search)";
					break;
				case 'startsWith':
					$searchSql = "($fieldName bắt đầu là $search)";
					break;
				}
				$dktim= $searchSql;
				$dmvtas = $dmDao->getDMSearch($searchType, $search, $searchMatch);

				$templateMgr->assign('searchSql', $searchSql);
				//$dmvtas = $dmDao->getSettingDM($journalid, $dmvt_initial);

			}
			else{
				$dktim= "Các Vật tư bắt đầu là <b>$dmvt_initial";
				$dmvtas = $dmDao->getSettingDM($journalid, $dmvt_initial);

			};


			$templateMgr->assign('dmvtas',  $dmvtas);
			$templateMgr->assign('dktim',  $dktim);

			$templateMgr->assign('DM_SecDetail', "Danh mục Vật tư");

			$dmtkDao =& DAORegistry::getDAO('DMTKDAO');
			$dstkvt =& $dmtkDao->getDSMATK("15");
			$tk_vt ='1561'; 
			$dstkgv =& $dmtkDao->getDSMATK("63");
			$tk_gv ='6321'; 
			$dstkdt =& $dmtkDao->getDSMATK("51");
			$tk_dt ='5111'; 

			$templateMgr->assign('dstkvt',  $dstkvt);
			$templateMgr->assign('tk_vt',  $tk_vt);
			$templateMgr->assign('dstkgv',  $dstkgv);
			$templateMgr->assign('tk_gv',  $tk_gv);
			$templateMgr->assign('dstkdt',  $dstkdt);
			$templateMgr->assign('tk_dt',  $tk_dt);


			$templateMgr->display('acctKT/dmvt.tpl');

		}

	}

	function KT_DMDVCS($args, &$request) {
		$this->setupTemplate();
		$templateMgr =& TemplateManager::getManager();
		$templateMgr->addStyleSheet($request->getBaseUrl().'/styles/dm.css');

		$dmDao =& DAORegistry::getDAO('DMDVCSDAO');
			// them phan Search


			$user =& Request::getUser();
			$userId = $user->getId();


			$searchType = null;
			$searchMatch = null;
			$search = Request::getUserVar('search');

			$searchInitial = Request::getUserVar('searchInitial');
			if (!empty($search)) {
				$searchType = Request::getUserVar('searchField');
				$searchMatch = Request::getUserVar('searchMatch');

			} elseif (!empty($searchInitial)) {
				$searchInitial = String::strtoupper($searchInitial);
				$searchType = USER_FIELD_INITIAL;
				$search = $searchInitial;
			}

			$fieldOptions = Array(
			DM_FIELD_MA => 'Mã ĐVCS',
			DM_FIELD_TEN => 'Tên ĐVCS'
				);

			$templateMgr->assign('fieldOptions', $fieldOptions);

			$templateMgr->assign('searchField', $searchType);
			$templateMgr->assign('searchMatch', $searchMatch);
			$templateMgr->assign('search', $search);
			$templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));

			if (!empty($search)) {
			$fieldName = $searchType;
			switch ($searchMatch) {
				case 'is':
					$searchSql = "($fieldName = $search)";
					break;
				case 'contains':
					$searchSql = "($fieldName có chứa $search)";
					break;
				case 'startsWith':
					$searchSql = "($fieldName bắt đầu là $search)";
					break;
				}
			}
			$templateMgr->assign('searchSql', $searchSql);

			$dms =& $dmDao->getDMDVCSSearch($searchType, $search, $searchMatch);
			$templateMgr->assign_by_ref('dms', $dms);
			//var_dump($dms);

			$templateMgr->display('acctKT/DMDVCS.tpl');


	//DMTK
	}


	function deleteDMTK($args) {
		$this->validate();
		if (isset($args) && !empty($args)) {
			$dmtkDao =& DAORegistry::getDAO('DMTKDAO');
			$dmtkDao->deleteTKByMa($args[0]);
		}
		$newurl= Request::url(null, null, "KT_DANHMUC"); 
		$newurl = $newurl."?ChiTiet=TK";

		PKPRequest::redirectUrl($newurl);
	}

	


	function createDMTK() {
		$this->editDMTK();
	}

	function editDMTK($args = array()) {
		$this->validate();
		$this->setupTemplate(true);

		import('classes.acct.form.DMTKForm');

		$DMTKForm = new DMTKForm(!isset($args) || empty($args) ? null : ( $args[0]));

		if ($DMTKForm->isLocaleResubmit()) {
			$DMTKForm->readInputData();
		} else {
			$DMTKForm->initData();
		}
		//var_dump($DMTKForm);
		$DMTKForm->display();
	}

	function updateDMTK($args) {

		$this->validate();
		$this->setupTemplate(true);
		import('classes.acct.form.DMTKForm');
		$DMTKForm = new DMTKForm(!isset($args) || empty($args) ? null : ($args[0]));

		$DMTKForm->validate();
		$DMTKForm->readInputData();
		$DMTKForm->execute();

		Request::redirect(null, null, 'KT_DMTK');
	}

	function DMTK_Ins() {
		$matk = strtoupper(Request::getUserVar('matk'));
		$oldma = strtoupper(Request::getUserVar('oldma'));
		$tentk = Request::getUserVar('tentk');
		$tieu_khoan = Request::getUserVar('tieu_khoan');
		$tk_me = Request::getUserVar('tk_me');
		$mode = Request::getUserVar('mode');

		if (strlen($matk) ==0 || strlen($tentk) ==0 )
		{
			echo "1. Phải nhập đủ mã, tên tài khoản!";
			return;
		}

		$dmDao =& DAORegistry::getDAO('DMTKDAO');
		if ($mode == 'edit'){
			$dmDao->update(
			'UPDATE DMTK SET matk = ?, tentk= ?, tieu_khoan=?, tk_me=?  where matk = ?',
			array(
				$matk,
				$tentk, 
				$tieu_khoan,
				$tk_me, 
				$oldma)
			);
		}
		else{
			$dmDao->update(
			'INSERT INTO DMTK
				(matk, tentk, tieu_khoan, tk_me)
				VALUES
				(?, ?, ?, ?)',
			array($matk, $tentk, $tieu_khoan, $tk_me)
			);
			
		}
		$result =& $dmDao->retrieve("select * from filecache where filename = 'dmtk' LIMIT 1");

		if ($result->RecordCount() == 0)
			$mysql = "INSERT INTO  filecache (`filename` ,`last_modified`) VALUES ('dmtk', '". date("Y-m-d H:i:s")."');";
		else
			$mysql = "UPDATE  filecache SET last_modified = '".date("Y-m-d H:i:s"). "' where filename = 'dmtk'";
		$dmDao->retrieve($mysql);
	}

	function DMDVCS_Ins() {
		$ma_dvcs = strtoupper(Request::getUserVar('ma_dvcs'));
		$oldma = strtoupper(Request::getUserVar('oldma'));
		$ten_dvcs = Request::getUserVar('ten_dvcs');
		$mode = Request::getUserVar('mode');

		if (strlen($ma_dvcs) ==0 || strlen($ten_dvcs) ==0 )
		{
			echo "1. Phải nhập đủ mã, tên ĐVCS!";
			return;
		}

		$dmDao =& DAORegistry::getDAO('DMDVCSDAO');
		if ($mode == 'edit'){
			$dmDao->update(
			'UPDATE DM_DVCS SET ma_dvcs = ?, ten_dvcs= ? where ma_dvcs = ?',
			array(
				$ma_dvcs,
				$ten_dvcs, 
				$oldma)
			);
		}
		else{
			$dmDao->update(
			'INSERT INTO DM_DVCS
				(ma_dvcs, ten_dvcs)
				VALUES
				(?, ?)',
			array($ma_dvcs, $ten_dvcs)
			);
			
		}
		$dmDao->retrieve($mysql);


		//matk, tentk
	}

	function DMDV_Ins() {
		$madv = strtoupper(Request::getUserVar('madv'));
		$oldma = strtoupper(Request::getUserVar('oldma'));
		$tendv = Request::getUserVar('tendv');
		$masothue = Request::getUserVar('masothue');
		$diachi = Request::getUserVar('diachi');
		$dienthoai = Request::getUserVar('dienthoai');
		$fax = Request::getUserVar('fax');
		$daidien = Request::getUserVar('daidien');
		$mode = Request::getUserVar('mode');


		if (strlen($tendv) ==0 || strlen($madv) ==0 )
		{
			echo "1. Phải nhập đủ mã, tên đơn vị!";
			return;
		}

		$dmDao =& DAORegistry::getDAO('DMDVDAO');
		if ($mode == 'edit'){
			$dmDao->update(
			'UPDATE DMDV SET madv = ?, tendv= ?, masothue =?, diachi=?, dienthoai=?, fax=?, daidien=?  where madv = ?',
			array(
				$madv,
				$tendv, 
				$masothue,
				$diachi, 
				$dienthoai, 
				$fax, 
				$daidien, 
				$oldma)
			);
		}
		else{
			$dmDao->update(
			'INSERT INTO DMDV
				(madv, tendv, masothue, diachi, dienthoai, fax, daidien)
				VALUES
				(?, ?,?,?,?,?,?)',
			array($madv, $tendv, $masothue, $diachi, $dienthoai, $fax, $daidien)
			);
			
		}
		$result =& $dmDao->retrieve("select * from filecache where filename = 'dmdv' LIMIT 1");

		if ($result->RecordCount() == 0)
			$mysql = "INSERT INTO  filecache (`filename` ,`last_modified`) VALUES ('dmdv', '". date("Y-m-d H:i:s")."');";
		else
			$mysql = "UPDATE  filecache SET last_modified = '".date("Y-m-d H:i:s"). "' where filename = 'dmdv'";
		$dmDao->retrieve($mysql);
	}

function DMDV_Del($args) {
		$madv = $args[0];
		$dmDao =& DAORegistry::getDAO('DMDVDAO');
		$dmDao->update('DELETE FROM dmdv WHERE madv = ?', array($madv));


		$result =& $dmDao->retrieve("select * from filecache where filename = 'dmdv' LIMIT 1");

		if ($result->RecordCount() == 0)
			$mysql = "INSERT INTO  filecache (`filename` ,`last_modified`) VALUES ('dmdv', '". date("Y-m-d H:i:s")."');";
		else
			$mysql = "UPDATE  filecache SET last_modified = '".date("Y-m-d H:i:s"). "' where filename = 'dmdv'";
		$dmDao->retrieve($mysql);

		$newurl= Request::url(null, null, "KT_DANHMUC", null, array('ChiTiet'=>"DV")); 
		//echo $newurl;

		PKPRequest::redirectUrl($newurl);

	}


	function DMVT_Ins() {
		$mavt = strtoupper(Request::getUserVar('mavt'));
		$oldma = strtoupper(Request::getUserVar('oldma'));
		$tenvt = Request::getUserVar('tenvt');
		$dvt = Request::getUserVar('dvt');
		$tk_gv = Request::getUserVar('tk_gv');
		$tk_dt = Request::getUserVar('tk_dt');
		$tk_vt = Request::getUserVar('tk_vt');

		$mode = Request::getUserVar('mode');

		if (strlen($tenvt) ==0)
		{
			echo "1. Không để trống nội dung!";
			return;
		}

		$dmDao =& DAORegistry::getDAO('DMVTDAO');
		if ($mode == 'edit'){
			$dmDao->update(
			'UPDATE DMVT SET mavt = ?, tenvt= ?, dvt=?, tk_vt=?, tk_gv=?, tk_dt=? where mavt = ?',
			array(
				$mavt,
				$tenvt,
				$dvt,
				$tk_vt,
				$tk_gv,
				$tk_dt,
				$oldma)
			);
		}
		else{
			$dmDao->update(
			'INSERT INTO DMVT
				(mavt, tenvt, dvt, tk_vt, tk_gv, tk_dt)
				VALUES
				(?, ?, ?, ?, ?, ?)',
			array(
				$mavt,
				$tenvt,
				$dvt,
				$tk_vt,
				$tk_gv,
				$tk_dt)
			);
			
		}

		$result =& $dmDao->retrieve("select * from filecache where filename = 'dmvt' LIMIT 1");

		if ($result->RecordCount() == 0)
			$mysql = "INSERT INTO  filecache (`filename` ,`last_modified`) VALUES ('dmvt', '". date("Y-m-d H:i:s")."');";
		else
			$mysql = "UPDATE  filecache SET last_modified = '".date("Y-m-d H:i:s"). "' where filename = 'dmvt'";
		$dmDao->retrieve($mysql);


	}


	function DMVT_Del($args) {
		$mavt = $args[0];
		$dmDao =& DAORegistry::getDAO('DMVTDAO');
		$dmDao->update('DELETE FROM dmvt WHERE mavt = ?', array($mavt));


		$result =& $dmDao->retrieve("select * from filecache where filename = 'dmvt' LIMIT 1");

		if ($result->RecordCount() == 0)
			$mysql = "INSERT INTO  filecache (`filename` ,`last_modified`) VALUES ('dmvt', '". date("Y-m-d H:i:s")."');";
		else
			$mysql = "UPDATE  filecache SET last_modified = '".date("Y-m-d H:i:s"). "' where filename = 'dmvt'";
		$dmDao->retrieve($mysql);

		$newurl= Request::url(null, null, "KT_DANHMUC", null, array('ChiTiet'=>"VT")); 
		//echo $newurl;

		PKPRequest::redirectUrl($newurl);

	}


	function DMDVCS_Del($args) {
		$ma_dvcs = $args[0];
		$dmDao =& DAORegistry::getDAO('DMDVCSDAO');
		$dmDao->update('DELETE FROM dm_dvcs WHERE ma_dvcs = ?', array($ma_dvcs));


		$newurl= Request::url(null, null, "KT_DMDVCS"); 
		//echo $newurl;

		PKPRequest::redirectUrl($newurl);

	}
	function setupTemplate($subclass = false) {
		$subclass = true;
		parent::setupTemplate();
		//AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_AUTHOR, LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_OJS_MANAGER));

		AppLocale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_OJS_MANAGER, LOCALE_COMPONENT_PKP_ADMIN));

		$templateMgr =& TemplateManager::getManager();
		if ($subclass) {
			$templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'user'), 'navigation.user')));
		}
	}


//	function setupTemplate($subclass = false) {
//		AppLocale::requireComponents(array(LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_PKP_READER));
//		parent::setupTemplate(true);
//		if ($subclass) {
//			$templateMgr =& TemplateManager::getManager();
//			$templateMgr->append('pageHierarchy', array(Request::url(null, 'manager', 'sections'), 'section.sections'));
//		}
//	}


}

?>
